package com.ytzl.gotrip.controller;

import com.ytzl.gotrip.model.GotripUserLinkUser;
import com.ytzl.gotrip.service.GotripUserLinkUserService;
import com.ytzl.gotrip.utils.common.Dto;
import com.ytzl.gotrip.utils.common.DtoUtil;
import com.ytzl.gotrip.vo.userinfo.ItripModifyUserLinkUserVO;
import com.ytzl.gotrip.vo.userinfo.ItripSearchUserLinkUserVO;
import io.swagger.annotations.ApiParam;
import org.springframework.data.repository.query.Param;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api/userinfo")
public class GoTripUserLinkUserController {
    @Resource
    private GotripUserLinkUserService gotripUserLinkUserService;
    @PostMapping("/queryuserlinkuser")
    public Dto queryUserLinkeUser(@RequestBody ItripSearchUserLinkUserVO itripSearchUserLinkUserVO,
                                  @ApiParam("token")@RequestHeader("token")String token,
                                 @ApiParam(hidden = true) @RequestHeader("user-agent")String Agent) throws Exception {
        List<GotripUserLinkUser> userLinkUserByUserId = gotripUserLinkUserService.getUserLinkUserByUserId(itripSearchUserLinkUserVO, token, Agent);
        return DtoUtil.returnDataSuccess(userLinkUserByUserId);
    }
    @GetMapping("/deluserlinkuser")
    public Dto delUserLinkUser(@RequestParam Long ids ,@ApiParam("token")@RequestHeader("token")String token,
                               @ApiParam(hidden = true) @RequestHeader("user-agent")String Agent) throws Exception {
        gotripUserLinkUserService.delUserLinkUserById(ids,token,Agent);
        return DtoUtil.returnSuccess("成功！");
    }
    @PostMapping("/modifyuserlinkuser")
    public Dto modifyUserLinkUser(@RequestBody ItripModifyUserLinkUserVO itripModifyUserLinkUserVO,
                                  @ApiParam("token")@RequestHeader("token")String token,
                                  @ApiParam(hidden = true) @RequestHeader("user-agent")String Agent       ) throws Exception {
            gotripUserLinkUserService.modifyUserLinkUser(itripModifyUserLinkUserVO,token,Agent);
        return DtoUtil.returnSuccess();
    }
    @PostMapping("/adduserlinkuser")
    public Dto adduserlinkuser(@RequestBody ItripModifyUserLinkUserVO itripModifyUserLinkUserVO,
                               @ApiParam("token")@RequestHeader("token")String token,
                               @ApiParam(hidden = true) @RequestHeader("user-agent")String Agent      ) throws Exception {
        gotripUserLinkUserService.addUserLinkUser(itripModifyUserLinkUserVO,token,Agent);

        return DtoUtil.returnSuccess();
    }
}
